package com.first.xiinn.service.impl;

import java.util.List;

import com.first.core.service.impl.BaseServiceImpl;
import com.first.xiinn.dao.DictionaryDao;
import com.first.xiinn.model.Dictionary;
import com.first.xiinn.service.DictionaryService;

public class DictionaryServiceImpl extends BaseServiceImpl<Dictionary>
		implements DictionaryService {
	private DictionaryDao dao;

	public DictionaryServiceImpl(DictionaryDao dao) {
		super(dao);
		this.dao = dao;
	}

	public List<Dictionary> getAllItems() {
		return this.dao.getAllItems();
	}

	public List<String> getAllByItemName(String itemName) {
		return this.dao.getAllByItemName(itemName);
	}

	@Override
	public void remove(String id) {
		String hql="delete from Dictionary where dicId=?";
		this.execHql(hql, new String[]{id});
	}
	
	public Dictionary get(String dicId){
		String hql="from Dictionary where dicId=?";
		List list= this.dao.findByHql(hql, new String[]{dicId});
		if(list!=null && !list.isEmpty()){
			return (Dictionary)list.get(0);
		}
		return new Dictionary();
	}

}
